//
//  UILabel+BackHeight.m
//  UITabelviewCellTwo
//
//  Created by lanou on 15/12/5.
//  Copyright (c) 2015年 MaZeGong. All rights reserved.
//

#import "UILabel+BackHeight.h"

@implementation UILabel (BackHeight)

/**
 * 返回自适应高度
 */
+ (CGFloat)backHeightWithString:(NSString *)string CGFloatCount:(CGFloat)count metho:(BackType) type font:(CGFloat)font
{
    if (![string isKindOfClass:[NSString class]]) {
        return 10;
    }
    // 创建字体大小的字典
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:font],NSFontAttributeName, nil];
    if (type == HEIGHT) {
        CGRect textRect = [string boundingRectWithSize:CGSizeMake(count, CGFLOAT_MAX) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
        return textRect.size.height;

    } else {
        CGRect textRect = [string boundingRectWithSize:CGSizeMake(CGFLOAT_MAX, count) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
        return textRect.size.width;

    }
   
}










@end
